#!/usr/bin/python
# coding:utf-8
# auther:DT
# 2017-08-12_11-33-10
A = "3+6*x^5+10*x^7+6*x^20"
B = "-15+7*x^3-6*x^5-10*x^8+12*x^20+17*x^25"
C = ""
for i in A.split("+"):
#    print(i)
    for g in B.split("-"):
        for h in g.split("+"):
#            print(h)
            for n in i.split("^"):
                print(n)
                for m h.split("^"):
                    if n == m:
                        C.join(i+g)
                        print(C)
